# https://api-1.onebound.cn/taobao/item_get/?key=t8336176519&num_iid=717265689181&is_promotion=1&&lang=zh-CN&secret=20231018

import requests

def parseTitle(url):
    
    try:
        goods_id = extract_id_parameter(url)
        print('goods_id', goods_id)
        response = requests.get("https://api-gw.onebound.cn/taobao/item_get/?key=t8336176519&num_iid=" + goods_id + "&is_promotion=1&&lang=zh-CN&secret=20231018")
        return response.json()['item']['title']  
    except:
        return 'None'
    
def extract_id_parameter(url):
    # 查找参数部分的起始位置
    param_start = url.find("?")
    
    # 如果找不到参数部分，返回 None
    if param_start == -1:
        return None

    # 截取参数部分
    params = url[param_start + 1:]
    
    # 拆分参数成键值对
    param_pairs = params.split("&")
    
    # 查找 id 参数
    for param_pair in param_pairs:
        key, value = param_pair.split("=")
        if key == "id":
            return value

    # 如果未找到 id 参数，返回 None
    return None
    
# print(parse('717265689181'))
